import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    language: localStorage.language ? localStorage.language : navigator.language.slice(0, 2),
  },
  mutations: {
    setLanguage(states, language) {
      states.language = language;
      localStorage.language = language;
    },
  },
  actions: {
    setLanguage(context, language) {
      context.commit('setLanguage', language);
    }
  }
})
